﻿using CodeGenerator.CodeGenBL;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using CodeGenerator.Models;

namespace CodeGenerator.Models
{
    public class AttributeModel
    {
        public int Id { get; set; }
        public ClassModel ClassModel { get; set; }
        public string Name { get; set; }
        public bool Display { get; set; }
        public bool Search { get; set; }
        public bool SearchResult { get; set; }
        public string FieldDescription { get; set; }
        public string Label { get; set; }
        public int Length { get; set; }
        public bool Autokey { get; set; }
        public bool Nullable { get; set; }
        public bool Pk { get; set; }
        public int SeqNo { get; set; }
        public int DisplayLengthInGrid { get; set; }
        public DataTypeModel DataType { get; set; }
        public FieldTypeModel FieldType { get; set; }
        //public IEnumerable<PickupListModel> PickupLists { get; set; }
        //public RelationshipModel Lookup { get; set; }

        public AttributeModel() { }

        public AttributeModel(AttributeModelDto dto) 
        {
            Id = dto.Id;
            Name = dto.Name;
            Display = dto.Display;
            Search = dto.Search;
            SearchResult = dto.SearchResult;
            FieldDescription = dto.FieldDescription;
            Label = dto.Label;            
            Length = dto.Length;
            Autokey = dto.AutoKey;
            Nullable = dto.Nullable;
            Pk = dto.Pk;
            SeqNo = dto.SeqNo;
            DisplayLengthInGrid = dto.DisplayLengthInGrid;
            DataType = new DataTypeModel(dto.DataType);
            FieldType = new FieldTypeModel(dto.FieldType);

        }

        public bool EdtitLinkField
        {
            get
            {
                return this.Pk == true;
            }
        }
    }
}
